package com.example.demo.task;

import com.example.demo.service.RecommendationService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class SimilarityCalculationScheduler {
    private final RecommendationService recommendationService;

    public SimilarityCalculationScheduler(RecommendationService recommendationService) {
        this.recommendationService = recommendationService;
    }

    // 每天凌晨3点计算相似度
//    @Scheduled(cron = "0 0 3 * * ?")
    @Scheduled(cron = "0 12 17 * * ?")
    public void calculateSimilarities() {
        System.out.println("开始计算相似度...");
        recommendationService.calculateUserSimilarities();
        recommendationService.calculateTorrentSimilarities();
        System.out.println("计算相似度完成...");
    }
}